import 'package:flutter/material.dart';
import 'package:flutterlogistics/ui/pages/home/guide_page.dart';
import 'package:flutterlogistics/ui/pages/home/home_page.dart';
import 'package:flutterlogistics/ui/pages/home/login_page.dart';
import 'package:flutterlogistics/ui/pages/home/selected_server_platform.dart';
import 'package:flutterlogistics/ui/pages/home/splash_page.dart';
import 'package:flutterlogistics/utils/log_util.dart';

// 跟路由
const routeRoot = '/';
// 主页面路由
const routeHome = '/route_home';
// 登录页面路由
const routeLogin = '/route_login';
// 启动页面路由
const routeSplash = '/route_splash';
// 引导页路由
const routeGuide = '/route_guide';
const routeServerPlatfrom = '/route_server_platfrom';

final routes = {
  routeRoot: (BuildContext context) =>  SplashPage(),
  routeLogin: (BuildContext context) =>  LoginPage(),
  routeHome: (BuildContext context) =>  HomePage(),
  routeGuide: (BuildContext context) =>  GuidePage(),
  routeServerPlatfrom: (BuildContext context) => ServerPlatfromPage(),
//  "/WeixinPhonePage": (BuildContext context) => new WeixinPhonePage(),
//  '/conversation': (context, {arguments}) {
//    print(arguments);
//    return ConversationPage(arguments: arguments);
};

// ignore: missing_return, top_level_function_literal_block
var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String name = settings.name;
  final Function pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }else{
    LogUtil.e("pageContentBuilder==null",tag: "router_config");
  }
};
